package com.flyqiu.flow.model.entity.base;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.flyqiu.common.mybaits.plus.type.MyBaitsFastJson2ObjectHandler;
import com.flyqiu.common.user.FlyQiuUser;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

@EqualsAndHashCode(callSuper = true)
@Data
public class Activity extends FlowBaseDao {

    @TableField("PROC_INST_ID_")
    private String procInstId;
    @TableField("ACT_TYPE_")
    private String actType;
    @TableField("ACT_INST_ID_")
    private String actInstId;
    @TableField("ACT_DEF_KEY_")
    private String defKey;
    @TableField("ACT_DEF_NAME_")
    private String defName;
    @TableField("ASSIGNEE_")
    private String assignee;
    @TableField("ASSIGNEE_KEY_")
    private String assigneeKey;
    /**
     * 办理人扩展属性
     */
    @TableField(value = "ASSIGNEE_ATTR_", typeHandler = MyBaitsFastJson2ObjectHandler.class)
    private JSONObject assigneeAttr;
    @TableField("ASSIGNEE_NICK_NAME_")
    private String assigneeNickName;
    /**
     * 办理人唯一key
     */
    @TableField("ASSIGNEE_UNIQUE_KEY_")
    private String assigneeUniqueKey;

    @TableField("CREATE_TIME_")
    private LocalDateTime createTime;
    @TableField("TENANT_ID_")
    private String tenantId;

    public static void setActivityAssignee(Activity activity, FlyQiuUser flyQiuUser) {
        activity.setAssignee(flyQiuUser.getId());
        activity.setAssigneeKey(flyQiuUser.getUserType());
        activity.setAssigneeNickName(flyQiuUser.getNickName());
        activity.setAssigneeUniqueKey(flyQiuUser.getUniqueKey());
        activity.setAssigneeAttr(flyQiuUser.getUserAttr());

    }
}
